//
//  UIImage+Shop.swift
//  shop
//
//  Created by 刘伟 on 2017/3/1.
//
//

import UIKit

extension UIImage {
    
    class func creatByColor(with withColor: UIColor) -> UIImage? {
        // 图片尺寸
        let rect = CGRect(x: 0, y: 0, width: 10, height: 10)
        // 填充画笔
        UIGraphicsBeginImageContext(rect.size)
        // 根据所传颜色绘制
        if let context = UIGraphicsGetCurrentContext() {
            let rectangle = CGRect(x: 0, y: 0, width: 10, height: 10)
            context.setFillColor(withColor.cgColor)
            context.setLineWidth(10)
            context.addRect(rectangle)
            UIGraphicsEndImageContext()
            let image = UIGraphicsGetImageFromCurrentImageContext()
            return image
        } else {
            return nil
        }
    }
}

extension UIImageView {
    
}
